<?php
/*
	本插件：$this->model('model')->方法名();
	其他地方调用：model('jy_dati/model')->方法名();
*/
namespace jy_dati;
defined('BY_JYA') or exit('error');
class model extends \plugin{
	public function getscore($content){
		$score=0;
		foreach($content as &$item){
			if($item['type']==4){
				if($item['data']==$item['daan']-1){
					$score +=$item['score'];
				}else{
					$item['nofen']=1;
				}
			}elseif($item['type']==5){
				$item['data']=str_array($item['data']);
				$zhong=0;
				foreach($item['data'] as $dv){
					$dv=$dv+1;
					if(strpos($item['daan'],';'.$dv.';') !== false){
						$zhong++;
					}else{
						$item['nofen']=1;
						break;
					}
				}
				if(!$item['nofen']){
					$item['daan']=str_array($item['daan']);
					$fen=intval($item['score']*$zhong/count($item['daan']));
					$score +=$fen;
				}
			}
		}
		$res=array('score'=>$score,'content'=>$content);
		return $res;
	}
}
?>